import numpy as np
import matplotlib.pyplot as plt
(fruitSalies,makeupSales)= np.loadtxt("mall_sales.csv",delimiter=",",skiprows=1,usecols=(1,4),unpack=True)
fruit_sales_r = np.diff(fruitSalies)/fruitSalies[:-1]
makeup_Sales_r = np.diff(makeupSales)/makeupSales[:-1]
covm = np.cov(fruit_sales_r,makeup_Sales_r)
print("协方差矩阵是:",covm)
convmDiag = covm.diagonal()
print("协方差矩阵对角线元素:",convmDiag)
convmTrc = covm.trace()
print("协方差矩阵的迹是:",convmTrc)
r = np.corrcoef(fruit_sales_r,makeup_Sales_r)
print("相关系数矩阵是:",r)
t = np.arange(len(fruit_sales_r))
plt.plot(t,fruit_sales_r,lw= 1)
plt.plot(t,makeup_Sales_r,lw =1)
plt.show()